import 'package:changxindianzishangwu/cache/local_cache.dart';
import 'package:changxindianzishangwu/http/base/http_urls.dart';
import 'package:changxindianzishangwu/util/app_color.dart';
import 'package:changxindianzishangwu/util/colors.dart';
import 'package:changxindianzishangwu/util/event_bus.dart';
import 'package:changxindianzishangwu/widget/app_bar.dart';
import 'package:flutter/material.dart';
import 'package:changxindianzishangwu/util/link_man_socket.dart';

class ContactSortingPage extends StatefulWidget {
  const ContactSortingPage({Key key}) : super(key: key);

  @override
  _ContactSortingPageState createState() => _ContactSortingPageState();
}

class _ContactSortingPageState extends State<ContactSortingPage> {
  @override
  void initState() {
    super.initState();
    _initEvent();
  }
  void _initEvent() {
    EventBus().addListener(EventKeys.EVENT_BUS_LINK_SOCKET, (arg) {
      print('---返回参数：${arg}');
    });
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: TopAppBar(context, "联系人"),
      body: Container(
        padding: EdgeInsets.all(width(15)),
        child: CustomScrollView(
          slivers: [
            SliverPersistentHeader(
              pinned: true,
              delegate: MySliverPersistentHeaderDelegate(),
            )
          ],
        ),
      ),
    );
  }

  @override
  void dispose() {
    LinkManSocket.instance.close();
    super.dispose();
  }
}

class MySliverPersistentHeaderDelegate extends SliverPersistentHeaderDelegate {
  @override
  Widget build(
      BuildContext context, double shrinkOffset, bool overlapsContent) {
    return Container(
        child: Text('在线时间排序',
            style: TextStyle(color:AppColor.colorGrey153)));
  }

  @override
  double get maxExtent => height(40);

  @override
  double get minExtent => height(40);

  @override
  bool shouldRebuild(SliverPersistentHeaderDelegate oldDelegate) =>
      true;
}
